import java.util.Scanner;
import java.lang.Math;

public class Car extends Vehicle
{
    private String vehicleid;
    private String brand;
    private String type;
    private float perRent;
    @Override
    public float calRent(int day)
    {
        float q;
        if(day<=7) q=day*super.getPerRent();
        else if(day<=30) q=(float) (0.9*day*getPerRent());
        else if(day<=150) q=(float) (0.8*day*getPerRent());
        else q=(float) (0.7*day*getPerRent());
        User.pay=q;
        return q;
    }
    @Override
    public boolean leaseOutFlow()
    {
        System.out.println("请选择你要租赁的轿车品牌：1.宝马 2.别克");
        Scanner in = new Scanner(System.in);
        int choice=in.nextInt();
        if(choice==1) {
            System.out.println("亲选择你要租赁的的轿车型号：1.550i 2.X6");
            int choice2 = in.nextInt();
            System.out.println("请输入您想要租赁的天数");
            int day = in.nextInt();
            String id = "京NY";
            id += (int) (10000 + 89999 * Math.random());
            if (choice2 == 1) {
                setVehicleid(id);
                setBrand("宝马");
                setType("550i");
                setPerRent(600);
                System.out.println("分配给您的汽车车牌号是：" + getVehicleid());
                System.out.println("您需要支付的租赁费用是：" + calRent(day));
                System.out.println(" 请问是否支付 : 1.支付  2.退出");
                int c = in.nextInt();
                if (c == 1) {
                    System.out.println("支付成功");
                    return true;
                } else {
                    System.out.println("支付失败");
                    return false;
                }
            } else {
                setVehicleid(id);
                setBrand("宝马");
                setType("X6");
                setPerRent(800);
                System.out.println("分配给您的汽车牌号是：" + getVehicleid());
                System.out.println("您需要支付的租赁费用是：" + calRent(day));
                System.out.println(" 请问是否支付 : 1.支付  2.退出");
                int c = in.nextInt();
                if (c == 1) {
                    System.out.println("支付成功");
                    return true;
                } else {
                    System.out.println("支付失败");
                    return false;
                }
            }
        }
        else
        {
            System.out.println("亲选择你要租赁的的轿车型号：1.林荫大道 2.GL8");
            int choice2=in.nextInt();
            System.out.println("请输入您想要租赁的天数");
            int day=in.nextInt();
            String id="京NY";
            id+=(int)(10000+89999*Math.random());
            if(choice2==1)
            {
                setVehicleid(id);
                setBrand("别克");
                setType("林荫大道");
                setPerRent(300);
                System.out.println("分配给您的汽车车牌号是："+getVehicleid());
                System.out.println("您需要支付的租赁费用是："+calRent(day));
                System.out.println(" 请问是否支付 : 1.支付  2.退出");
                int c = in.nextInt();
                if(c==1)
                {
                    System.out.println("支付成功");
                    return true;
                }
                else
                {
                    System.out.println("支付失败");
                    return false;
                }
            }
            else
            {
                setVehicleid(id);
                setBrand("别克");
                setType("GL8");
                setPerRent(600);
                System.out.println("分配给您的汽车车牌号是："+getVehicleid());
                System.out.println("您需要支付的租赁费用是："+calRent(day));
                System.out.println(" 请问是否支付 : 1.支付  2.退出");
                int c = in.nextInt();
                if(c==1)
                {
                    System.out.println("支付成功");
                    return true;
                }
                else
                {
                    System.out.println("支付失败");
                    return false;
                }
            }
            }
        }
    }

